package com.zhiyou100.crowd.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zhiyou100.IService.QuestionService;
import com.zhiyou100.entity.TbQuestion;
/*常见问题*/
@RequestMapping("question/")
@Controller
public class QuestionController {
	@Resource(name="qusetionServiceimp")
	private QuestionService questionServiceimp;
	@RequestMapping("cop.do")
	public String queryQuestion(HttpServletRequest request) {
		List<TbQuestion> list_one = questionServiceimp.queryQuestionOne();
		List<TbQuestion> list_two = questionServiceimp.queryQuestionTwo();
		List<TbQuestion> list_thr = questionServiceimp.queryQuestionThr();
		List<TbQuestion> list_for = questionServiceimp.queryQuestionFor();
		request.getSession().setAttribute("one_t", list_one.get(0).getQuestionTitle());
		request.getSession().setAttribute("two_t", list_two.get(0).getQuestionTitle());
		request.getSession().setAttribute("thr_t", list_thr.get(0).getQuestionTitle());
		request.getSession().setAttribute("for_t", list_for.get(0).getQuestionTitle());
		request.getSession().setAttribute("list_ones", list_one);
		request.getSession().setAttribute("list_twos", list_two);
		request.getSession().setAttribute("list_thrs", list_thr);
		request.getSession().setAttribute("list_fors", list_for);
		
		return "cop";
	}
	@RequestMapping("updatea.do")
	public String updateq(Integer id,String title,String name,String answer) {
		questionServiceimp.updateq(id,title,name,answer);
		return "forward:question/cop.do";
	}
}
